package org.vectrics.recruiter.struts.admin;

import javax.servlet.jsp.JspException;

import org.apache.log4j.Category;
import org.vectrics.hibernate.ThreadProperties;
import org.vectrics.recruiter.user.JobAgentsBatch;
import org.vectrics.struts.VectricsActionData;
import org.vectrics.struts.VectricsStrutsAction;


public class InvokeJobAgentAction extends VectricsStrutsAction {
    private static Category log = Category.getInstance(InvokeJobAgentAction.class);
	public static String JOB_ID_PARAM = "jobId";


	// Intercept 
	public String doExecute(VectricsActionData actionData)	throws JspException {
		log.debug("InvokeJobAgentAction.execute() - called");
		JobAgentsBatch invoker =  new JobAgentsBatch(ThreadProperties.getDomain());
		try {
			invoker.run();
		} catch (Exception ex) {
			throw new JspException("Exception running job agent process", ex);
		}
		
		ShowAdminIndex.initialize(actionData.getRequest());
		
		return ("success");
	}
	
}
